// 导入 axios
import axios from '@/utils/request.js'

// 1.获取频道文章数据---------------------------------
export const getComments = ({ type = 'a', source = -1, offset = null, limit = 10 }) => {
  return axios({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type,
      source,
      offset,
      limit
    }
  })
}

// 2.获取频道文章数据---------------------------------
export const likeCMT = (id) => {
  return axios({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target: id
    }
  })
}

// 3.获取频道文章数据---------------------------------
export const dislikeCMT = (id) => {
  return axios({
    method: 'DELETE',
    url: `/v1_0/comment/likings/${id}`
  })
}

// 4.添加评论或评论回复---------------------------------
export function addComment(target, content, art_id = null) {
  return axios({
    method: 'POST',
    url: '/v1_0/comments',
    data: {
      target,
      content,
      art_id
    }
  })
}
